<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$act=$_GET['act'];
if($act=='ok'){
   if(!$_POST[adminpost]){
	   echo"提交出错<br/>";
   }else{
   	 $_POST['sms_post_password']=authcode($_POST['sms_post_password'],'ok','Bingz');
	   Bingz_config('sms_post_sezhi',$_POST['sms_post_sezhi'],'post');
	   Bingz_config('sms_post_username',$_POST['sms_post_username'],'post');
	   Bingz_config('sms_post_password',$_POST['sms_post_password'],'post');
	   Bingz_config('sms_post_key',$_POST['sms_post_key'],'post');
     echo"提交成功<br/>";
	 }
   echo "正在自动返回.......<br/><a href=\"admin.php?action=sms\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=sms'>";
}elseif($act=='postok'){
   if(!$_POST[adminpost]){
	   echo"提交出错<br/>";
   }elseif(Bingz_config('sms_post_sezhi') == '0' ){
	   echo"请先开启短信发送<br/>";
   }elseif(!$_POST[sms] or !$_POST[name] ){
	   echo"不能为空<br/>";
   }elseif(!preg_match("/^1[0-9]{1}[0-9]{9}$/",$_POST[sms])){
	   echo"手机号格式错误<br/>";
   }elseif(Bingz_sms_post($_POST['sms'],$_POST['name']) == '1'){
        echo"发送成功<br/>";
   }else{
        echo"发送失败！<br/>";
	 }
   echo "正在自动返回.......<br/><a href=\"admin.php?action=sms&act=post\">请手动返回</a><br/><meta http-equiv=refresh content='30;url=admin.php?action=sms&act=post'>";
}elseif($act=='post'){
	$mobile=$_GET['mobile'];
echo <<<end
<a href="admin.php?action=sms">返回短信配置</a><br/>
<div class="admin">==发送短信==<br/></div>
	<form  method="post" action="admin.php?action=sms&act=postok">
	发送手机号:<br/>
	 <input class="text" type="text" name="sms" value="$mobile"  />
<br/>
  短信内容:(注意70字内)<br/>
  <textarea class="textarea" type="text" name="name" placeholder="请输内容" ></textarea><br/>
	<input class="submit" type="submit" name="adminpost" value="立即发送" />
</form>
	<br/>
end;
}elseif($act=='pzok'){
   if(!$_POST[adminpost]){
	   echo"提交出错<br/>";
   }else{
	   Bingz_config('sms_user_post',$_POST['sms_user_post'],'post');
	   Bingz_config('sms_user_post_lx',$_POST['sms_user_post_lx'],'post');
	   Bingz_config('sms_user_post_money',$_POST['sms_user_post_money'],'post');

	   Bingz_config('sms_set_reg',$_POST['sms_set_reg'],'post');
	   Bingz_config('sms_set_reg_body',$_POST['sms_set_reg_body'],'post');
	   
	   Bingz_config('sms_set_editpwd',$_POST['sms_set_editpwd'],'post');
	   Bingz_config('sms_set_editpwd_body',$_POST['sms_set_editpwd_body'],'post');
	   
	   Bingz_config('sms_set_payment',$_POST['sms_set_payment'],'post');
	   Bingz_config('sms_set_payment_body',$_POST['sms_set_payment_body'],'post');
     echo"提交成功<br/>";
	 }
   echo "正在自动返回.......<br/><a href=\"admin.php?action=sms\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=sms'>";
}else{
if(Bingz_config('sms_post_sezhi') == '1'){$sms_post_sezhi='selected="selected"';}else{$sms_post_sezhia='selected="selected"';}
$sms_post_username=Bingz_config('sms_post_username');
$sms_post_password=authcode(Bingz_config('sms_post_password'),'DECODE','Bingz');
$sms_post_key=Bingz_config('sms_post_key');

if(Bingz_config('sms_user_post') == '1'){$sms_user_post='selected="selected"';}else{$sms_user_posta='selected="selected"';}
if(Bingz_config('sms_user_post_lx') == 'jifen'){$sms_user_post_lx='selected="selected"';}elseif(Bingz_config('sms_user_post_lx') == 'money'){$sms_user_post_lxa='selected="selected"';}elseif(Bingz_config('sms_user_post_lx') == 'yeobi'){$sms_user_post_lxb='selected="selected"';}elseif(Bingz_config('sms_user_post_lx') == 'renminbi'){$sms_user_post_lxc='selected="selected"';}
$sms_user_post_money=Bingz_config('sms_user_post_money');


if(Bingz_config('sms_set_reg') == '1'){$sms_set_reg='selected="selected"';}else{$sms_set_rega='selected="selected"';}
$sms_set_reg_body=Bingz_config('sms_set_reg_body');
if(Bingz_config('sms_set_editpwd') == '1'){$sms_set_editpwd='selected="selected"';}else{$sms_set_editpwda='selected="selected"';}
$sms_set_editpwd_body=Bingz_config('sms_set_editpwd_body');
if(Bingz_config('sms_set_payment') == '1'){$sms_set_payment='selected="selected"';}else{$sms_set_paymenta='selected="selected"';}
$sms_set_payment_body=Bingz_config('sms_set_payment_body');
	     
	     $smsfsb='http://sms.wapv.net/index.php?m=plugin&insert=Bingz_smscat&mod=sms_balance&name='.$sms_post_username.'&pass='.$sms_post_password.'&key='.$sms_post_key.'&time='.$time.'';
       $contentzt=@file_get_contents(''.$smsfsb.'');//http://sms.wapv.net
       if($contentzt != '0' && $contentzt < '0' ){
          $contentzt='账号错误';
       }
echo <<<end
<div class="admin">==短信配置==<br/></div>
  获取短信币：(<font color="#FF0000">$contentzt</font>)<br/>
	<form  method="post" action="admin.php?action=sms&act=ok">
  短信发送:<select name="sms_post_sezhi">
<option value="1" $sms_post_sezhi >开启</option>
<option value="0" $sms_post_sezhia >关闭</option>
</select><br/>
	平台用户名:(<a href="http://sms.wapv.net">守护者sms.wapv.net</a>)<br/>
	<input class="ipt-text" type="text" name="sms_post_username" value="$sms_post_username" />
<br/>
	平台密码:(<a href="http://sms.wapv.net">守护者sms.wapv.net</a>)<br/>
	<input class="ipt-text" type="password" name="sms_post_password" value="$sms_post_password" />
<br/>
	平台kye:(<a href="http://sms.wapv.net">守护者sms.wapv.net</a>)<br/>
	<input class="ipt-pass" type="password" name="sms_post_key" value="$sms_post_key" />
<br/>
	<input class="submit" type="submit" name="adminpost" value="提交修改" />
</form>  <a href="admin.php?action=sms&act=post">发送短信</a><br/>
<br/>

	<b>发送规则</b><br/>
	<form  method="post" action="admin.php?action=sms&act=pzok">
	(1)<u>会员发短信</u>:<select name="sms_user_post">
<option value="1" $sms_user_post >开启</option>
<option value="0" $sms_user_posta >关闭</option>
</select><br/>
	会员可以在用户中心发送短信<br/>
  扣除金额模式</u>:<select name="sms_user_post_lx">
<option value="jifen" $sms_user_post_lx >经验</option>
<option value="money" $sms_user_post_lxa >金币</option>
<option value="yeobi" $sms_user_post_lxb >游戏币</option>
<option value="renminbi" $sms_user_post_lxc >人民币</option>
</select><br/>
	每条扣除金额:<br/>
	<input class="texta" type="text" name="sms_user_post_money" value="$sms_user_post_money" />
<br/>

	(2)<u>注册会员</u>:<select name="sms_set_reg">
<option value="1" $sms_set_reg >通知</option>
<option value="0" $sms_set_rega >不通知</option>
</select><br/>
	注册会员成功后发送短信通知<br/>
	短信内容:(注意70字内)<br/>
	<textarea class="textarea" name="sms_set_reg_body"  >$sms_set_reg_body</textarea>
<br/>
	
	(3)<u>修改密码</u>:<select name="sms_set_editpwd">
<option value="1" $sms_set_editpwd >通知</option>
<option value="0" $sms_set_editpwda >不通知</option>
</select>
<br/>
	会员修改密码后是否短信通知<br/>
	短信内容:(注意70字内)<br/>
	<textarea class="textarea" name="sms_set_editpwd_body" >$sms_set_editpwd_body</textarea>
<br/>
	
	(4)<u>付款成功</u>:<select name="sms_set_payment">
<option value="1" $sms_set_payment >通知</option>
<option value="0" $sms_set_paymenta >不通知</option>
</select>
<br/>
	会员订单付款完成是否短信通知<br/>
	短信内容:(注意70字内)<br/>
	<textarea class="textarea" name="sms_set_payment_body" >$sms_set_payment_body</textarea>
<br/>
	<input class="submit" type="submit" name="adminpost" value="提交修改" />
</form>
	<br/>
end;
}
?>